<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/SharedPages/SharedPage.jsp"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="language" value="${not empty param.language ? param.language : not empty language ? language : pageContext.request.locale}" scope="session" />
<fmt:setLocale value="${language}" />
<fmt:setBundle basename="properties.text" />
<title><fmt:message key="candidate" /></title>
<link rel="stylesheet" type="text/css" href="/jt-hr-WEB/css/styles.css">
<script type="text/javascript" src="candidate.js"></script>
</head>

<body>
	<form id="selectlanguage" name="selectlanguage">
            <select id="language" name="language" onchange="submit()">
                <option value="en" ${language == 'en' ? 'selected' : ''}>English</option>
                <option value="de" ${language == 'de' ? 'selected' : ''}>Deutsch</option>
                <option value="ro" ${language == 'ro' ? 'selected' : ''}>Romana</option>
            </select>
    </form>
	<div id="header">
	    <div id="img">
        	<img class="center" src="/jt-hr-WEB/img/msg_header.jpg" height="100px" width="500px"/>    
    		<jsp:include page="/SharedPages/SharedPage.jsp"></jsp:include>
    	</div>
    </div>
    <div class="content">
    	  <h3 align="center">Candidates</h3>
    
    <jsp:useBean id="operationIsSuccesful" class="java.lang.String" scope="session"/>
    <jsp:setProperty name="operationIsSuccesful" property="*" />
    
	<br>
	<div class="alert-box success" id="succes" style="display:none;margin-left:5%"><span ><fmt:message key="succes" />:</span><fmt:message key="succesm" /></div>
	<br>
	
	<%
		if(operationIsSuccesful=="yes"){
			%>
			<script>
				document.getElementById("succes").style.display='inline';
			</script>
			<% 
		}
	 %>
	    
	<jsp:useBean id="candidate" class="entityJPA.Candidate" scope="session" />
	<jsp:useBean id="list" class="java.util.Vector<Candidate>"
		scope="session" />
	<jsp:useBean id="index" class="java.lang.Integer" scope="session" />
	<jsp:setProperty name="candidate" property="*" />
	<jsp:setProperty name="list" property="*" />
	<%@ page import="entityJPA.*"%>
	<%@ page import="java.util.Vector"%>
	<%@ include file="candidateSearch.jsp"%>
	<%@ include file="candidateNavigation.jsp"%>
	<table border=2 class="infoTable" align="center">
		<th><fmt:message key="firstname" /></th>
		<th><fmt:message key="lastname" /></th>
		<th><fmt:message key="cellnumber" /></th>
		<th><fmt:message key="email" /></th>
		<th><fmt:message key="positionName" /></th>
		<th><fmt:message key="cv" /></th>
		<th><fmt:message key="comments" /></th>
		<th><fmt:message key="interviews" /></th>
		<%
			for (int i = index;i < index + 5 && i < list.size(); i++) {
		%>
		<tr onclick="populateFields(this);" style="cursor: pointer;text-align: center">
			<td style="display: none;"><%=list.get(i).getIdCandidate()%></td>
			<td><%=list.get(i).getFirstName()%></td>
			<td><%=list.get(i).getLastName()%></td>
			<td style="display: none;"><%=list.get(i).getHomeNumber()%></td>
			<td><%=list.get(i).getCellNumber()%></td>
			<td><%=list.get(i).getEmail()%></td>
			<td style="display: none;"><%=list.get(i).getAddress()%></td>
			<td style="display: none;"><%=list.get(i).getRelocation()%></td>
			<td><%=list.get(i).getPosition().getName()%></td>
			<td style="display: none;"><%=list.get(i).getCvUpload()%></td>
			<td style="display:none"><%=list.get(i).getPosition().getIdPosition()%></td>
			<form action="cvServlet" method="POST">
				<td><input type="submit" value=<fmt:message key="download" /> name="downloadCV" /></td>
				<input type="hidden" id="idCandidate" name="idCandidate"
					value="<%=list.get(i).getIdCandidate()%>" />
			</form>
			<td><a
				href="http://localhost:8080/jt-hr-WEB/candidate/candidateComment?idCandidate=<%=list.get(i).getIdCandidate()%>"><fmt:message key="comments" /></a></td>
			<td><a
				href="http://localhost:8080/jt-hr-WEB/candidate/interviewServlet?idCandidate=<%=list.get(i).getIdCandidate()%>"><fmt:message key="interviews" /></a></td>
		</tr>
		<%
			}
		%>

	</table>
	<div align="center"  style="display:block;
	margin:0 auto" >
	-<%=" " +(index / 4 + 1)+ " "%>-
	</div>
	<c:if
		test="<%=request.getSession().getAttribute("savedUserType")
						.equals("Director General")
						|| request.getSession().getAttribute("savedUserType")
								.equals("Recruiter")%>">
			<%@ include file="candidate.jsp"%>
	</c:if>
				<% if (request.getSession().getAttribute("savedUserType").equals("Director HR")||
			request.getSession().getAttribute("savedUserType").equals("Recruiter")||
			request.getSession().getAttribute("savedUserType").equals("Director Department")){
			%>
			<a href="/jt-hr-WEB/directorDepartamentPages/directorDepartamentPage.jsp" id="backbutton"><fmt:message key="back" /></a>
			<%} else {
				if (request.getSession().getAttribute("savedUserType").equals("Director General"))
			%>
			<a href="/jt-hr-WEB/directorGeneralPages/directorGeneralPage.jsp" id="backbutton"><fmt:message key="back" /></a>
			<%} %>
	
	</div>
<script>
	var lang='<c:out value="${language}"/>';
	select=document.getElementById("language");
	if(lang=="de_DE"||lang=="de"){
		select.options[1].defaultSelected=true;
	}
	else if(lang=="ro_RO"||lang=="ro"){
		select.options[2].defaultSelected=true;
	}
	else {
		select.options[0].defaultSelected=true;
	}

	
</script>
</body>
</html>